package com.wtwd.campus.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wtwd.campus.entity.SysOrg;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wtwd.campus.entity.SysOrgPermission;
import com.wtwd.campus.model.vo.OrgTreeVO;
import com.wtwd.campus.model.vo.PermissionTreeVO;
import com.wtwd.campus.model.vo.SysOrgVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zdl
 * @since 2021-06-08
 */
@Mapper
public interface SysOrgMapper extends BaseMapper<SysOrg> {
    IPage<SysOrgVO> querylist(@Param("page") Page<SysOrg> page, @Param("sysOrg") SysOrg sysOrg);

    List<SysOrg> listOrgByPid(Integer pid);

    int deleteOrgPermissionByOrgId(Integer orgId);

    int deleteOrgPermissionByOrgIdsAndPermissionIds(@Param("orgIds") List<Integer> orgIds,@Param("permissionIds") List<Integer> permissionIds);



    int saveOrgPermissionBatch(@Param("params") List<SysOrgPermission> params);

    List<SysOrg> listOrgByOrgCode(String orgCode);

    List<OrgTreeVO> listOrgIncludeSchoolByOrgCode(String orgCode);


    List<PermissionTreeVO> listOrgPermissionByOrgId(Integer orgId);

    String getOrgCodeById(Integer orgId);

    SysOrg getSysOrgByOrgCode(@Param("orgCode") String orgCode);

    SysOrg getSysOrgById(@Param("orgId") Integer orgId);

    List<SysOrg> getOverdueSysOrg(@Param("time") long time);

    /**
     * 续约组织及其下级
     * @param orgCode
     * @return
     */
    int renewSysOrgAndSub(@Param("orgCode") String orgCode,@Param("exipreTime")Long expireTime);

    List<Map<String,Object>> getExpirationOrg(@Param("timeMax") Long timeMax,@Param("timeMin") Long timeMin);
}
